<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>商品详情</title>
            <link rel="stylesheet" href="../css/Common.css">
            <link rel="stylesheet" href="../css/media.css">
        <link rel="stylesheet" href="../css/3.1-details.css">
        <link rel="stylesheet" type="text/css" href="../font/iconfont.css">
</head>
<body>
     <!-- 头部 -->
     <header>
            <a href="javascript:;"><span class="iconfont icon-fanhui"></span></a>
            <span>国内折扣</span>
            <a href="javascript:;"><img src="../images/header_app.png" alt=""></a>
    </header>
  <!-- 商品详情 -->
    <div class="details clearfix">
       
    </div>
</body>
</html>
<script src="../lib/jquery-1.12.4.min.js"></script>
<script src="../lib/template.js"></script>
<script type="text/template" id="datailsList">

    {{each result as val key}}
                <div>
                        <div class="name">{{val.productName}}</div>
                        <span></span><span></span><span></span>
                        <div class="content1">
                            <div class="content1_left"></div>
                            <div class="content1_right"></div>
                        </div>
                        <div class="content2"></div>
                        <div class="imgLg">{{val.productImgLg}}</div>  
                </div>
    {{/each}}
</script>
<script>
    $(function(){
        // getUrl()
        //获取url 中的参数
        function getUrl(name){
            var reg=new  RegExp("(^|&)" + name + "=([^&]*)(&|$)");//构造一个含有目标参数的正则表达式对象
            var  r=window.location.search.substr(1).match(reg);//匹配目标参数
            if (r != null) return unescape(r[2]); return null;//返回参数值
            
        }
        //接收url中的参数
        var id = getUrl('id')
 $.ajax({
            url:'http://193.112.55.79:9090/api/getmoneyctrlproduct',
            type:'get',
            dataType:'json',
            data:{
                productid:id
            },
            success:function(res){
                console.log(res)
                template.config("escape", false);
                var str=template('datailsList',res);
                
                //动态渲染页面
             $('.details').append(str);
            }
        })

    })
    // rander();
    // function rander(productId){
      
    // }

</script>